﻿namespace NTracker.Tests.Injection
{
    using NUnit.Framework;
    using Rhino.Mocks;
    using NTracker.Injection;
    using System.Reflection;
    using System.Collections.Generic;
    using NTracker.Tests.Mock;
    
    [TestFixture]
    public class DependencyCatalogTests
    {
        private DependencyCatalog catalog;
        private Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject wrapper;

        [TestFixtureSetUp]
        public void SetUp()
        {
            catalog = DependencyCatalog.Instance;
            wrapper = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(catalog);
        }

        [Test]
        public void LoadAssemblies()
        {
            // Given
            List<Assembly> actual;

            // When
            actual = (List<Assembly>)wrapper.Invoke("LoadAssemblies");

            // Then
            Assert.IsNotEmpty(actual);
        }

        [Test]
        public void PopulateCatalog_WhenFindAssembly()
        {
            // Given
            int notExpected = 0;

            // When
            wrapper.Invoke("PopulateCatalog", new List<Assembly> { Assembly.GetAssembly(typeof(Sample)) });

            // Then
            Assert.AreNotEqual(notExpected, catalog.Dependencies.Count);
        }
    }
}
